package org.example.controller;

import org.example.dto.*;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Rongchang Wu
 */
@RestController
public class BasicController {
    /**
     * 获取全部学年
     *
     * @return 学年集合
     */
    @GetMapping("/getSchoolYear")
    public List<SchoolYearDto> getSchoolYear() {
        List<SchoolYearDto> schoolYearList = new ArrayList<>();
        SchoolYearDto schoolYear1 = new SchoolYearDto();
        schoolYear1.setValue(2024);
        schoolYear1.setText("2024-2025");
        schoolYearList.add(schoolYear1);
        SchoolYearDto schoolYear2 = new SchoolYearDto();
        schoolYear2.setValue(2023);
        schoolYear2.setText("2023-2024");
        schoolYearList.add(schoolYear2);
        //以上从service获取学年信息，存入schoolYearList集合


        return schoolYearList;
    }

    /**
     * 获取全部学期
     *
     * @return 学期集合
     */
    @GetMapping("/getSemester")
    public List<Integer> getSemester() {
        List<Integer> semesterList = new ArrayList<>();
        semesterList.add(1);
        semesterList.add(2);
        semesterList.add(3);

        return semesterList;
    }

    /**
     * 获得全部系别
     *
     * @return 系别集合
     */
    @GetMapping("/getDepartment")
    public List<DepartmentDto> getDepartment() {
        List<DepartmentDto> DepartmentList = new ArrayList<>();

        DepartmentDto d1 = new DepartmentDto();
        d1.setDepartmentId(1);
        d1.setDepartmentName("软件工程");
        DepartmentList.add(d1);
        DepartmentDto d2 = new DepartmentDto();
        d2.setDepartmentId(2);
        d2.setDepartmentName("计算机科学与技术");
        DepartmentList.add(d2);
        //以上service调用返回系别信息给DepartmentList

        return DepartmentList;
    }

    /**
     * 根据系别名获得对应的专业
     *
     * @param departmentName 系别名
     * @return 专业集合
     */
    @GetMapping("/getMajorByDepartment")
    public List<MajorDto> getMajorByDepartment(String departmentName) {
        System.out.println("进入/getMajorByDepartment");
        List<MajorDto> majorList = new ArrayList<>();
        MajorDto m1 = new MajorDto();
        m1.setMajorId(1);
        m1.setMajorName("软件工程");
        majorList.add(m1);
        MajorDto m2 = new MajorDto();
        m2.setMajorId(2);
        m2.setMajorName("大数据分析");
        majorList.add(m2);
        //以上从service根据系别获取专业信息

        return majorList;
    }

    /**
     * 根据专业名查找年级
     *
     * @param majorName 专业名
     * @return 年级集合
     */
    @GetMapping("/getGradeByMajor")
    public List<GradeDto> getGradeByMajor(String majorName) {
        List<GradeDto> gradeList = new ArrayList<>();
        GradeDto m1 = new GradeDto();
        m1.setGradeId(1);
        m1.setGradeName("19软件");
        gradeList.add(m1);
        GradeDto m2 = new GradeDto();
        m2.setGradeId(2);
        m2.setGradeName("18软件");
        gradeList.add(m2);
        //以上从service根据专业名获取年级信息

        return gradeList;
    }

    /**
     * 根据年级名查找班级
     *
     * @param gradeName 年级名
     * @return 班级集合
     */
    @GetMapping("/getClassByGrade")
    public List<ClassDto> getClassByGrade(String gradeName) {
        List<ClassDto> classList = new ArrayList<>();
        ClassDto c1 = new ClassDto();
        c1.setClassName("19软件（春）四班");
        classList.add(c1);
        ClassDto c2 = new ClassDto();
        c2.setClassName("19软件（春）三班");
        classList.add(c2);
        //以上从service根据年级名获取班级信息

        return classList;
    }

    /**
     * 查询所有教师
     *
     * @return 教师集合
     */
    @GetMapping("/getTeacher")
    public List<TeacherDto> getTeacher() {
        List<TeacherDto> teacherList = new ArrayList<>();
        TeacherDto t1 = new TeacherDto();
        t1.setTeacherName("万念斌");
        teacherList.add(t1);
        TeacherDto t2 = new TeacherDto();
        t2.setTeacherName("洪阿兰");
        teacherList.add(t2);
        //以上从service获取教师信息

        return teacherList;
    }

    @GetMapping("/getBuilding")
    public List<BuildingDto> getBuilding() {
        List<BuildingDto> buildingList = new ArrayList<>();
        BuildingDto b1 = new BuildingDto();
        b1.setBuildingId(1);
        b1.setBuildingName("博学苑1");
        buildingList.add(b1);
        BuildingDto b2 = new BuildingDto();
        b2.setBuildingId(2);
        b2.setBuildingName("博学苑3");
        buildingList.add(b2);
        //以上从service获取教学楼信息

        return buildingList;
    }

}
